//2009/08/23 02:19:04
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class CyclicWords
{
public:
    int differentCW(vector <string> words)
    {
		set<string> v;
		for(int i=0; i<words.size(); i++)
		{
			string s(words[i]);
			for(int j=1; j<words[i].size(); j++)
			{
				string temp = words[i].substr(j) + words[i].substr(0,j);
				if(temp < s) s = temp;
			}
			v.insert(s);
		}
		return v.size();
    }
};
